package com.itboye.mengwu.app.ui.mymeng;

import java.text.SimpleDateFormat;
import java.util.Observable;
import java.util.Observer;

import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.core.alert.ByAlert;
import com.itboye.core.object.BaseActivity;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.R;
import com.itboye.mengwu.data.model.OrderDetailBean;
import com.itboye.mengwu.data.model.OrderQueryModel;
import com.itboye.mengwu.data.model.OrderQueryModel.OrderList;
import com.itboye.mengwu.data.presenter.OrderPresenter;

public class ActivityOrderDetail extends BaseActivity implements Observer{
	OrderQueryModel model;
	TextView total_price,address,goods_num,dengdaipingjia,txt_reciever_name,mobile,jiaoyi_status,yunfei,finalJiage,orderNo,setUpTime,chengjiaoTime;
	LinearLayout goods_container;
	Button shenqingshouhou,qupingjia;
	private String id;
	private OrderList orderBean;
	OrderPresenter orderPresenter;
	OrderDetailBean orderDetailbean;
	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.order_detail;
	}

	@Override
	public void onMyCreate() {
		showProgressDialog("数据加载中，请稍后", true);
		orderPresenter=new OrderPresenter(this);
		model=(OrderQueryModel) getIntent().getSerializableExtra("model");
		id=getIntent().getStringExtra("id");
		orderPresenter.getXiangQing(id);
	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity=handlerError(data);
		if(entity!=null){
			orderDetailbean=(OrderDetailBean) entity.getData();
			finalJiage.setText("￥"+orderDetailbean.getPrice());
			txt_reciever_name.setText(orderDetailbean.getContactname());
			mobile.setText(orderDetailbean.getMobile());
			yunfei.setText(orderDetailbean.getPostPrice());
			orderNo.setText(orderDetailbean.getOrderCode());
			setUpTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Integer.parseInt(orderDetailbean.getCreatetime())*1000));
			chengjiaoTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Integer.parseInt(orderDetailbean.getUpdatetime())*1000));
			goods_num.setText("共"+orderDetailbean.getCount()+"件");
			address.setText(orderDetailbean.getProvince()+orderDetailbean.getCity()+orderDetailbean.getarea()+"\n"+orderDetailbean.getDetailinfo());
		}
		try {
			closeProgressDialog();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
